
OBJS_C = arm_heap.o 
SRCS_C := $(OBJS_C:.o=.c)

OBJS_ASM = head.o 
SRCS_ASM := $(OBJS_ASM:.o=.S)

SUBDIRS = $(SOC_VENDOR)

SUB_BUILT_IN_OBJS := $(foreach n, $(SUBDIRS), $(n)/$(BUILT_IN_OBJ))

all : $(SUBDIRS) $(BUILT_IN_OBJ)

$(SUBDIRS): 
	@make -C $@ all

$(BUILT_IN_OBJ): $(OBJS_ASM) $(OBJS_C) $(SUB_BUILT_IN_OBJS)
	$(LD) -r $(LDFLAGS) -o $@ $^

$(OBJS_ASM): $(SRCS_ASM)
	$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $(@:.o=.S)

$(OBJS_C): $(SRCS_C)
	$(CC) $(CFLAGS) -c $(@:.o=.c)

clean:
	@for dir in $(SUBDIRS); do \
		make -C $$dir clean; \
	 done	
	@rm -vf *.o

.PHONY: $(SUBDIRS)

